/**	\file		Builder.h
*	\author		Abbas Bazzi
*	\author		Farah Charab
*	\author		Rafah El-Khatib
*	\brief		A header file that gives mathematical meaning to our programming language. That is, it evaluates the correctness of the inputted set of mathematical statements by appropriately traversing the constructed graph. It builds an augmented tree with augmented nodes to check the consistency between the given and the parsed grammar according to each node's assigned functionality and value.
*/

#ifndef _BUILDER_H_
#define _BUILDER_H_
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>
#include "RealGraph.h"
using namespace std;

/**	\brief		Function that removes duplicate elements and returns a sorted output.	
	\param		Vec is a vector of vectors of strings which can be regarded as a set.
*/
void RemoveDuplicates(vector < vector<string> > & Vec );
/**	\brief		Function that remove duplicate elements and returns a sorted output.	
	\param		Vec is a vector of vectors of strings which can be regarded as a map.
*/
void RemoveMapDuplicates(vector<vector< vector<string> > > & Vec );
/**	\brief		Function that casts a string representation into an integer representation.
	\return		Integer equivalent of passed parameter.
*/
int IntTok(string  s);
/**	\brief		Function that casts a string representation into a double representation.
	\return		Double equivalent of passed parameter.
*/
double RealTok(string  s);
/**	\brief		Function that transforms a tuple into a set of entities that the tuple consists of. That is, it casts a single string representation into a vector of string representations. The initial tuple representation is of the form "[a,b,c]", for example, and the final representation is a vector, where the first three entries are the strings "a", "b", and "c".
	\return		Vector of strings, each representing a separate entity of the passed tuple.
*/
vector<string> TupleTok(string a);
/**	\brief		Function that transforms a set of tuples into a set of separate entities that the tuples consist of. That is, it casts a single string representation into a vector of string representations. The initial set representation is of the form "{[a,b],[c,d],[e,f]}", for example. First, this is converted into a vector, where the first three entries are the strings "[a,b]", "[c,d]", and "[e,f]". Then, finally, the function TupleTok is called, so each of the three strings just mentioned is converted into a vector of the basic entities. The final representation is a vector where the first six entries are the strings "a", "b", "c", "d", "e", and "f".
	\return		Vector of vectors of strings. Each element of outer vector represents a tuple in the set, and each element of the inner vector represents a separate entity of the corresponding tuple.
*/
vector<vector<string> > SetTok(string  a);
/**	\brief		Function that transforms a relation into a set of entities that the relation consists of. That is, it casts a single string representation into a vector of two string representations. The initial relation representation is of the form "a->b", for example, and the final representation is a vector, where its two entries are the strings "a" and "b".
	\return		Vector of strings, with the first representing the initial node in a relation and the second representing the final node in it.
*/
vector<vector<string> > RelationTok(string  a);
/**	\brief		Function that transforms a map of relations into a set of separate entities that the relations consist of. That is, it casts a single string representation into a vector of string representations. The initial set representation is of the form "<(a->b),(c->d)>", for example. First, this is converted into a vector, where the first two entries are the strings "(a->b)" and "(c->d)". Then, finally, the function RelationTok is called, so each of the two strings just mentioned is converted into a vector of the basic entities. The final representation is a vector where the first four entries are the strings "a", "b", "c", and "d".
	\return		Vector of vectors of strings. Each element of outer vector represents a relation in the map, and the two elements of the inner vector represent respectively the initial and final nodes of the corresponding relation.
*/
vector<vector<vector<string> > > MapTok(string  a);
/**	\typedef	ValueType
	\brief		Enumerator that contains all possible values that can be taken by a node. It is used to distinguish between types of entities, including natural numbers, real numbers, tuples, sets, relations, and maps.
*/
typedef enum {IntVal, RealVal, TupleVal, SetVal, RelationVal, MapVal, FlagVal} ValueType;

/**	\class		Value
	\brief		Base Class which contains virtual functions. It will be used by inheritance in other classes. It holds the value of a node, which may be an integer number, real number, tuple, set, relation, or map. To work on all classes that inherit from it, it has to contain the appropriate "get" functions (get type, integer value, real value, tuple representation, set representation, relation representation, and map representation).
*/
class Value {
public:
	virtual double CastDouble()const=0; 
        virtual ValueType getType()const=0; 
	virtual int getInt() const =0; 
      	virtual double getReal() const=0; 
	virtual vector<string> getTuple() const=0; 
	virtual vector<vector<string> > getSet() const=0;
	virtual vector<vector<string> > getRelation() const=0; 
	virtual vector<vector<vector<string> > > getMap() const=0; 
};
/**	\class		IntValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type integer number, and so only makes use of the functions related to integer numbers.
*/

class IntValue: public Value {public:
        int val;
	IntValue (int v): val(v){};
	IntValue (string v) {
		val=IntTok(v);
	}
	int getInt() const { return val;}
	double CastDouble()const {return static_cast<double>(val);}
        ValueType getType() const {return IntVal;}
	double getReal() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}

};
/**	\class		FlagValue
	\brief		Class that inherits from the Base Class Value. It is used to indicate that a certain variable has no assigned value.
*/
class FlagValue: public Value {public:
 	bool val;
	FlagValue (bool v) : val(v){};
 	int getInt() const { return val;}
	bool getFlag() const{ return val;}
	double CastDouble()const {return static_cast<double>(val);}
        ValueType getType() const {return FlagVal;}
	double getReal() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}
};
/**	\class		RealValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type real number, and so only makes use of the functions related to real numbers.
*/
class RealValue: public Value {public:
        double val;
	RealValue (double v) : val(v) {}
	RealValue (string v){
		val=RealTok(v);
	}
	double getReal() const {return val;}
	double CastDouble()  const{return val;}
        ValueType getType()  const{return RealVal;}
	int getInt() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}

};
/**	\class		TupleValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type tuple, and so only makes use of the functions related to tuples.
*/
class TupleValue: public Value {public:
        vector< string >  val;
	TupleValue (vector<string> v) : val(v){}
	TupleValue (string v){
		val = TupleTok(v);	
	}
	vector <string> getTuple() const {return val;}
	double CastDouble() const {return static_cast<double>(val.size());}
        ValueType getType() const {return TupleVal;}
	int getInt() const {return 0;}
	double getReal() const{return 0;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}

};
/**	\class		SetValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type set, and so only makes use of the functions related to sets.
*/
class SetValue: public Value {public:
        vector< vector <string > >  val;
	SetValue (vector<vector<string> > v){ RemoveDuplicates(v); val=v;}
	SetValue (string v){
		val = SetTok(v);	
	}
	vector<vector<string> > getSet()  const{return val;}
	double CastDouble() const {return static_cast<double>(val.size());}
        ValueType getType() const {return SetVal;}
	int getInt() const {return 0;}
	double getReal() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}

};
/**	\class		RelationValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type relation, and so only makes use of the functions related to relations.
*/
class RelationValue: public Value {public:
        vector< vector <string > >  val;
	RelationValue (vector<vector<string> > v) : val(v){}
	RelationValue (string v){
		val = RelationTok(v);	
	}
	double CastDouble() const {return 0;}
	vector < vector <string> > getRelation() const {return val;}
        ValueType getType() const  {return RelationVal;}
	int getInt() const {return 0;}
	double getReal() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<vector<string> > > getMap() const{vector<vector<vector<string> > > empty; return empty;}

};
/**	\class		MapValue
	\brief		Class that inherits from the Base Class Value. It holds the value of a node of type map, and so only makes use of the functions related to maps.
*/
class MapValue: public Value {public:
        vector< vector <vector<string > > > val;
	MapValue (vector< vector< vector< string> > >v) {RemoveMapDuplicates(v); val=v;}
	MapValue (string v){
		val = MapTok(v);	
	}
	double CastDouble() const  {return static_cast<double>(val.size());}
	vector < vector < vector< string> > > getMap() const {return val;}
        ValueType getType()  const {return MapVal;}
	int getInt() const {return 0;}
	double getReal() const{return 0;}
	vector<string> getTuple() const{vector<string>empty;return empty;}
	vector<vector<string> > getSet() const{vector<vector<string> > empty; return empty;}
	vector<vector<string> > getRelation() const{vector<vector<string> >empty; return empty;}

};
/**	\class		BaseNode
	\brief		Base Class which contains virtual functions. It will be used by inheritance in other classes. It holds the value of a node, as defined in the base class Value, the name of a node, the name appended to its numerical identifier (to ensure uniqueness of nodes' names), the node's type (literal, expression, statement, or variable), and a vector of adjacent nodes. It also has functions that implement the addition of an adjacent node to the corresponding member vector, setting the base node's value, and evaluating functions.
*/
class BaseNode {
public:
	BaseNode();
	string name;
	string fakename;
	string type;
	vector<BaseNode*>AdjNodes;
	void print(){
		cout<<name<<": "<<endl;
			for(int i=0;i<AdjNodes.size();i++) 
				cout<<AdjNodes[i]->name<<" "; 
			cout<<endl;
	}
	void AddAdjNode(BaseNode* a){AdjNodes.push_back(a);}
	BaseNode(string n,string f, string t):name(n),fakename(f),type(t){}
	Value *Val;
	void SetBaseNodeVal(Value * v){Val=v;};
	virtual Value* Evaluate() const=0; // virtual functions for evaluating an operator node
	virtual Value* Evaluate(Value*,Value*)const=0;
	virtual Value* Evaluate(Value*) const=0;
	virtual Value* Evaluate(Value*,BaseNode*)const=0;
	
};

/**	\class		OperandNode
	\brief		Class that inherits from the Base Class BaseNode. It holds a node which is either a variable or a literal, and so only makes use of the functions related to them.
*/
class OperandNode :public BaseNode{
public:

	OperandNode(string n,string f,string t,Value*v): BaseNode(n,f,t){BaseNode::Val=v;};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoAdd
	\brief		Class that inherits from the Base Class BaseNode. It performs the addition of two operands and returns their sum. It only makes use of the appropriate Evaluate function.
*/
class PianoAdd:public BaseNode{
public:
	PianoAdd(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoSub
	\brief		Class that inherits from the Base Class BaseNode. It performs the subtraction of two operands and returns their difference. It only makes use of the appropriate Evaluate function.
*/
class PianoSub:public BaseNode{
public:
	PianoSub(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoMult
	\brief		Class that inherits from the Base Class BaseNode. It performs the multiplication of two operands and returns their product. It only makes use of the appropriate Evaluate function. ???
*/
class PianoMult:public BaseNode{
public:
	PianoMult(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoDiv
	\brief		Class that inherits from the Base Class BaseNode. It performs the division of two operands and returns their quotient. It only makes use of the appropriate Evaluate function.
	\note		Division by zero is not allowed and the program exits if that is attempted.
*/
class PianoDiv:public BaseNode{
public:
	PianoDiv(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoIsLess
	\brief		Class that inherits from the Base Class BaseNode. It performs the comparison of two operands and returns 1 if the first is less than the second and zero otherwise. It only makes use of the appropriate Evaluate function. 
*/
class PianoIsLess:public BaseNode{
public:
	PianoIsLess(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoIsGreater
	\brief		Class that inherits from the Base Class BaseNode. It performs the comparison of two operands and returns 1 if the first is greater than the second and zero otherwise. It only makes use of the appropriate Evaluate function.
*/
class PianoIsGreater:public BaseNode{
public:
	PianoIsGreater(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};

/**	\class		PianoIsEqual
	\brief		Class that inherits from the Base Class BaseNode. It performs the comparison of two operands and returns 1 if the first is equal to the second and zero otherwise. It only makes use of the appropriate Evaluate function.
*/
class PianoIsEqual:public BaseNode{
public:
	PianoIsEqual(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoAnd
	\brief		Class that inherits from the Base Class BaseNode. It performs the AND of two operands and returns 1 if the both are equal to 1 and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The operands of the AND operation must be of integer value. Otherwise, the program exits. ???(0/1 or 0/nonzero?)
*/
class PianoAnd:public BaseNode{
public:
	PianoAnd(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoOr
	\brief		Class that inherits from the Base Class BaseNode. It performs the OR of two operands and returns 1 if either one of them is equal to 1 and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The operands of the OR operation must be of integer value. Otherwise, the program exits. ???(0/1 or 0/nonzero)
*/
class PianoOr:public BaseNode{
public:
	PianoOr(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoNot
	\brief		Class that inherits from the Base Class BaseNode. It performs the NOT of an operand and returns 1 if the operand is equal to 0 and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The operand of the NOT operation must be of integer value. Otherwise, the program exits. ???(0/1 or 0/nonzero?)
*/
class PianoNot:public BaseNode{
public:
	PianoNot(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoUnion
	\brief		Class that inherits from the Base Class BaseNode. It performs the UNION of two sets and returns the resultant set. It only makes use of the appropriate Evaluate function.
	\note		The operands of the UNION operation are only allowed to be Sets. Otherwise, the program exits.
*/
class PianoUnion:public BaseNode{
public:
	PianoUnion(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoIntersection
	\brief		Class that inherits from the Base Class BaseNode. It performs the INTERSECTION of two sets and returns the resultant set. It only makes use of the appropriate Evaluate function.
	\note		The operands of the INTERSECTION operation are only allowed to be Sets. Otherwise, the program exits.
*/
class PianoIntersection:public BaseNode{
public:
	PianoIntersection(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoCartesianPro
	\brief		Class that inherits from the Base Class BaseNode. It performs the CARTESIAN PRODUCT of two sets and returns the resultant set. It only makes use of the appropriate Evaluate function.
	\note		The operands of the CARTESIAN PRODUCT operation are only allowed to be Sets. Otherwise, the program exits.
*/
class PianoCartesianPro:public BaseNode{
public:
	PianoCartesianPro(string n,string f, string t):BaseNode(n,f,t){ 			
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**   \class    PianoScalarPro
      \brief    Class that inherits from the Base Class BaseNode. It performs the SCALAR PRODUCT of two sets and returns the resultant set. It only makes use of the appropriate Evaluate function.
      \note	This function gets evaluated only when the first operand is of type real or int, and the second operand is a set of tuples of real or integer entries.
	\note		The first operand of the SCALAR PRODUCT operation is only allowed to be a number (real number or integer). The second operand is only allowed to be a Set. The tuples forming the set must be represented in numerical form (For example [a,b] and [1,a] are not acceptable, but [1,2] is.) Otherwise, the program exits.
*/
class PianoScalarPro:public BaseNode{
public:
	PianoScalarPro(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoIsSub
	\brief		Class that inherits from the Base Class BaseNode. It checks whether one operand is a subset of the other and returns 1 if so and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The operands of the ISSUB operator are only allowed to be Sets. Otherwise, the program exits.
*/
class PianoIsSub:public BaseNode{
public:
	PianoIsSub(string n,string f, string t):BaseNode(n,f,t){ 					
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoAssign
	\brief		Class that inherits from the Base Class BaseNode. It takes two operands ,checks if they agree, and returns a boolean value accordingly. It only makes use of the appropriate Evaluate function.
	\note		If the type of the two operands' types are inconsistent, the program exits.
*/
class PianoAssign:public BaseNode{
public:
	PianoAssign(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value *operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};

/**	\class		PianoSetIsEqual
	\brief		Class that inherits from the Base Class BaseNode. It checks whether or not two sets are equal and returns 1 if so and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The operands of the SETISEQUAL operator are only allowed to be Sets. Otherwise, the program exits.
*/

class PianoSetIsEqual:public BaseNode{
public:
	PianoSetIsEqual(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value * Evaluate (Value * operand1, Value* operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoComplement
	\brief		Class that inherits from the Base Class BaseNode. It takes two sets as operands, a subset and its parent set. It finds the subset's complement inside the larger set and returns the resultant set found. It only makes use of the appropriate Evaluate function.
	\note		The operands of the COMPLEMENT operator are only allowed to be Sets. The size of the first operand must be greater than that of the second. The first operand must be a superset of the second. Otherwise, the program exits.
*/
class PianoComplement:public BaseNode{
public:
	PianoComplement(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1,Value* operand2)const;
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoCardinality
	\brief		Class that inherits from the Base Class BaseNode. It finds the CARDINALITY of an operand. It only makes use of the appropriate Evaluate function.
	\note		The operand of the CARDINALITY operator is only allowed to be a Set. Otherwise, the program exits.
*/
class PianoCardinality:public BaseNode{
public:
	PianoCardinality(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1)const;
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};

};
/**	\class		PianoComposition
	\brief		Class that inherits from the Base Class BaseNode. It performs the COMPOSITION of maps. It only makes use of the appropriate Evaluate function.
	\note		The operands of the COMPOSITION operator are only allowed to be Maps. The domain and codomain of the maps must match. Otherwise, the program exits.
*/
class PianoComposition:public BaseNode{
public:
	PianoComposition(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1 ,Value* operand2)const;
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoSubstitution
	\brief		Class that inherits from the Base Class BaseNode. Given a Set and a Map , it replaces elements of tuples of this set by their image if given by the Map. It only makes use of the appropriate Evaluate function.
	\note		The first and second operands of the SUBSTITUTION operator are only allowed to be Map and Set, respectively. The first operand, the map, can only be between two tuples, each of size 1. Otherwise, the program exits.
*/
class PianoSubstitution:public BaseNode{
public:
	PianoSubstitution(string n,string f, string t):BaseNode(n,f,t){		
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1 ,Value* operand2)const;
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};

};
/**	\class		PianoProjection
	\brief		Class that inherits from the Base Class BaseNode. It performs the PROJECTION of a Set given a Map, so it basically gets the image of the set. Alternatively it performs PROJECTION of a Map on a Set, that it returns the codomain of the Map that belongs to the Set. It only makes use of the appropriate Evaluate function.
	\note		The first and second operands of the SUBSTITUTION operator are only allowed to be Map and Set, respectively, or Set and Map, respectively. Otherwise, the program exits.
*/
class PianoProjection:public BaseNode{
public:
	PianoProjection(string n,string f, string t):BaseNode(n,f,t){ 
		BaseNode::Val=new IntValue(0);};

	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1 ,Value* operand2)const;
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		PianoExist
	\brief		Class that inherits from the Base Class BaseNode. It checks whether or not a tuple exists inside a set. It returns 1 if so and zero otherwise. It only makes use of the appropriate Evaluate function.
	\note		The first and second operands of the SUBSTITUTION operator are only allowed to be Tuple and Set, respectively. Otherwise, the program exits.
*/
class PianoExist:public BaseNode{
public:
	PianoExist(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1,Value* operand2)const;
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,BaseNode*) const{
		Value* empty= new IntValue(0);
		return empty;
	};

};
/**	\class		PianoThereExists
	\brief		Class that inherits from the Base Class BaseNode. It checks whether or not there exists a tuple in a given set that satisfies a certain condition. It only makes use of the appropriate Evaluate function.
	\note		The condition for the THEREEXISTS operator must be a comparison with a numerical value. Otherwise, the program exits.
*/
class PianoThereExists:public BaseNode{
public:
	PianoThereExists(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};


	Value* Evaluate(Value*,Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value* operand1,BaseNode* operand2) const;

};

/**	\class		PianoForEvery
	\brief		Class that inherits from the Base Class BaseNode. It checks whether or not every tuple in a given set satisfies a certain condition. It only makes use of the appropriate Evaluate function.
	\note		The condition for the FOREVERY operator must be a comparison with a numerical value. Otherwise, the program exits.
*/
class PianoForEvery:public BaseNode{
public:
	PianoForEvery(string n,string f, string t):BaseNode(n,f,t){
		BaseNode::Val=new IntValue(0);};
	Value* Evaluate(Value* operand1,BaseNode * operand2)const;
	Value* Evaluate() const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*,Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
	Value* Evaluate(Value*)const{ 
		Value* empty= new IntValue(0);
		return empty;
	};
};
/**	\class		AugEdge
	\brief		Class that represents an edge, contains two pointers, one to the parent node and one to the child node, and the edge's weight (whether it is a left or a right edge with respect to its own parent node).
*/
class AugEdge{
public:
	BaseNode *from;
	BaseNode *to;
	string weight;
	AugEdge(BaseNode *a,BaseNode*b,string w):from(a),to(b),weight(w){}
};
/**	\class		AugTree
	\brief		Represents the tree that contains a vector of nodes, their indices in the vector with respect to the nodes' modified names (original name appended with a numerical identifier to ensure uniqueness), and functions that take care of adding nodes and edges.
*/
class AugTree{
public:
	vector<BaseNode*> Nodes;
	map<string,int> FakeToIndex;
	void addNode(BaseNode* a){
		FakeToIndex[a->fakename]=Nodes.size();
		Nodes.push_back(a);
	}
	void addEdge(AugEdge e){
		BaseNode* Source = e.from;
		BaseNode* Destination = e.to;
		Source->AddAdjNode(Destination);
	};
	void print(){for (int i=0;i<Nodes.size();i++) Nodes[i]->print();}
	
};
/**	\class		CheckTree
	\brief		Class that contains an augmented tree constructed by its member function TreeConstructor, which takes two inputs: a Real Graph and a text file which contains input values. 
	\note		The function traverses the tree constructed in it. It parses the input, propagates the assigned values of the variables, and checks whether or not the input is satisfied. In case some variables still need to be assigned values, the program outputs "Need more information". In case the input is not satisfied, the program outputs "Not satisfied". Else, the program outputs "Satisfied".
*/
class CheckTree {
public:
	void TreeConstructor(RealGraph G,string Check);
	AugTree newTree;
	map<string,string> AssignedValue;
	vector<BaseNode*> SpecialNodes;
	vector<BaseNode*> PotentialRoots;
	vector<BaseNode*> RootsOfSpecialNodes;
};

#endif
	
